package com.itheima.d9_test02;

import java.util.Collections;

public class Hero implements Comparable<Hero> {
    private String name;
    private int survive;        // 生存
    private int attack;         // 攻击
    private int effect;         // 效果
    private double score;          // 分数



    public Hero() {
    }




    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getSurvive() {
        return survive;
    }

    public void setSurvive(int survive) {
        this.survive = survive;
    }

    public int getAttack() {
        return attack;
    }

    public void setAttack(int attack) {
        this.attack = attack;
    }

    public int getEffect() {
        return effect;
    }

    public void setEffect(int effect) {
        this.effect = effect;
    }

    public Hero(String name, int survive, int attack, int effect) {
        this.name = name;
        this.survive = survive;
        this.attack = attack;
        this.effect = effect;
        this.score = survive * 0.5 + attack * 0.2 + effect * 0.3;
    }

    public double getScore() {
        return score;
    }

    public void setScore(double score) {
        this.score = score;
    }

    @Override
    public String toString() {
        return name +"," +survive +","+attack+","+effect+","+score ;
    }

    @Override
    public int compareTo(Hero o) {
        return Double.compare(o.score,score);
    }
}
